package com.igoal.service.dwr;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.igoal.service.SaveResult;
import com.igoal.service.UserManagerExt;

@Service("wallPostManagerDWR")
public class WallPostManagerDWRImpl extends BaseDWRService implements WallPostManagerDWR {

	private UserManagerExt userManagerExt;

	@Autowired
	public void setUserManagerExt(UserManagerExt userManagerExt) {
		this.userManagerExt = userManagerExt;
	}

	public long addPost(String wallOwner, String thought, String privacy) {
		if (!isLoginUser()) {
			debug("User session is expired");
			return 0;
		}
		String postOwner = getUserInSession();
		return userManagerExt.addWallPost(postOwner, wallOwner, thought, privacy);
	}

	public int deletePost(Long id) {
		if (!isLoginUser()) {
			debug("User session is expired");
			return SaveResult.FAIL;
		}
		return userManagerExt.deleteWallPost(id, getUserInSession());
	}

}
